package com.chinacoal.microservice.controller;

import com.alibaba.fastjson.JSONObject;
import com.chinacoal.microservice.CostManagementClient;
import com.chinacoal.microservice.pojo.*;
import com.chinacoal.microservice.service.CostManagementService;
import com.chinacoal.microservice.util.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.*;
import java.util.List;

/**
 * @author zhuliang
 * @version V1.0
 * @Description: 运维模块-费用管理-后端控制类
 * @date 2020-11-25 20：19
 */
@RestController
public class CostManagementController implements CostManagementClient {

    @Autowired
    private CostManagementService costManagementService;

    /**
     * @Description: 查询所有的费用信息(带分页)
     * @author zhuliang
     * @date 2020/11/27 9:51
     */
    @Override
    @UserLoginToken
    public Result<List<CcmsSmartleasingExpenseManag>> getAllByExpenseManag(QueryCriteria queryCriteria, String token) {
        return costManagementService.getAllByExpenseManag(queryCriteria, token);
    }

    /**
     * @Description: 条件查询所有的费用信息(带分页)
     * @author zhuliang
     * @date 2020/11/27 10:37
     */
    @Override
    @UserLoginToken
    public Result<List<CcmsSmartleasingExpenseManag>> getAllExpenseManagByCondition(QueryCriteria queryCriteria, String token) {
        return costManagementService.getAllExpenseManagByCondition(queryCriteria, token);
    }


    /**
     * @Description: 通过费用信息id查询相关历史付费
     * @author liule
     * @date 2022/10/09
     */
    @Override
    @UserLoginToken
    public Result<List<CcmsSmartleasingHistoricalPayment>> getHistoricalPaymentsByExpenseManagId(String fkExpenseManagId, String token) {
        return costManagementService.getHistoricalPaymentsByExpenseManagId(fkExpenseManagId, token);
    }
    /**
     * @Description: 通过费用信息id查询费用详情
     * @author zhuliang
     * @date 2020/11/27 11:34
     */
    @Override
    @UserLoginToken
    public Result<CcmsSmartleasingNotice> getNoticeByContractId(String fkExpenseManagId, String token) {
        return costManagementService.getNoticeByContractId(fkExpenseManagId, token);
    }

    /**
     * @Description: 通过费用信息id得到要抄表所需要回显的信息
     * @author zhuliang
     * @date 2020/11/27 14:01
     */
    @Override
    @UserLoginToken
    public Result<CcmsSmartleasingExpenseManag> meterReadingByExpenseManagId(String pkExpenseManagId, String token) {
        return costManagementService.meterReadingByExpenseManagId(pkExpenseManagId, token);
    }

    /**
     * @Description: 录入抄表信息
     * @author zhuliang
     * @date 2020/11/27 14:25
     */
    @Override
    @UserLoginToken
    public Result addMeterReadingInformation(CcmsSmartleasingExpenseEntry expenseEntry, String token) {
        return costManagementService.addMeterReadingInformation(expenseEntry, token);
    }

    @Override
    @UserLoginToken
    public Result importMeterReadingInformations(MultipartFile file, String token) {
        return costManagementService.importMeterReadingInformations(file, token);
    }

    /**
     * 获取下载模版
     */
    @Override
    public void downloadTemplateFile(HttpServletResponse response,String token) {
        this.costManagementService.downloadTemplateFile(response,token);
    }

    @Override
    @UserLoginToken
    public Result lockCost(String token) {
        return this.costManagementService.lockCost(token);
    }

    /**
     * @Description: 缴费
     * @author zhuliang
     * @date 2020/12/4 18:00
     */
    @Override
    @UserLoginToken
    public Result pay(CcmsSmartleasingExpenseManag expenseManag, String token) {
        return costManagementService.pay(expenseManag, token);
    }

    /**
     * @Description: 审核的回显信息获取
     * @author zhuliang
     * @date 2020/12/5 10:03
     */
    @Override
    @UserLoginToken
    public Result<CcmsSmartleasingNotice> getAuditEcho(String pkExpenseManagId, String token) {
        return costManagementService.getAuditEcho(pkExpenseManagId, token);
    }

    /**
     * @Description: 抄表审核
     * @author zhuliang
     * @date 2020/12/5 11:02
     */
    @Override
    @UserLoginToken
    public Result meterReadingReview(CcmsSmartleasingExpenseEntry expenseEntry, String token) {
        return costManagementService.meterReadingReview(expenseEntry, token);
    }

    /**
     * @Description: 线下开票
     * @author zhuliang
     * @date 2020/12/5 17:54
     */
    @Override
    @UserLoginToken
    public Result offlineInvoicing(CcmsSmartleasingExpenseManag expenseManag, String token) {
        return costManagementService.offlineInvoicing(expenseManag, token);
    }

    /**
     * @Description: 通过费用信息id的字符串集合来进行批量开票
     * @author zhuliang
     * @date 2020/11/30 9:44
     */
    @Override
    @UserLoginToken
    public Result invoicing(String pkExpenseManagId, String token) {
        return costManagementService.invoicing(pkExpenseManagId, token);
    }

    /**
     * @Description: 得到发票接口返回值
     * @author zhuliang
     * @date 2021/2/1 15:27
     */
    @Override
    public Result getInvoicing(String result, String token, String orderNumber) {
        return costManagementService.getInvoicing(result, token, orderNumber);
    }

    @Override
    public void exportSummaryReport(HttpServletResponse response,String startDate,String endDate,List<String> areaNumberIds, String token) {
       costManagementService.exportSummaryReport(response,startDate,endDate,areaNumberIds,token);
    }

    @Override
    public void exportSummaryReportByClient(HttpServletResponse response,String startDate,String endDate,List<String> areaNumberIds, String token) {
        costManagementService.exportSummaryReportByClient(response,startDate,endDate,areaNumberIds,token);
    }

    @Override
    public void exportDebtDetailReport(HttpServletResponse response, String startDate, List<String> areaNumberIds,String token) {
        costManagementService.exportDebtDetailReport(response,startDate,areaNumberIds,token);
    }


}
